<?php
namespace scripts;
use QYS\Protocol\Response;
use QYS\Protocol\Request;
use QYS\Task\Factory;
use QYS\Db\Mysql;
use QYS\Util\Debug;
use QYS\Log\Log;
use QYS\Db\Redis;
use globalunit\utils\DBClass;
use globalunit\utils\Config;
use globalunit\utils\JWTUtil;
use globalunit\utils\RequestHelper;
use globalunit\utils\Utils;
use globalunit\utils\KeysUtil;
use globalunit\utils\Common;
use QYS\Core\Config as QYSConfig;
use QYS\QYS;
class Header
{
    public function header($request,$response,$params)
    {
        $response->addHeader("Content-Type", 'application/json');
        $response->addHeader("Access-Control-Allow-Origin", "*");
        $response->addHeader("Access-Control-Allow-Methods", 'POST, GET, OPTIONS, DELETE');
        $response->addHeader('Access-Control-Allow-Headers', "Origin, X-Requested-With, Content-Type, Accept");
        $response->sendHttpHeader();
        if ($request->getRequest()->server['request_method'] == 'OPTIONS') {
            $response->say("");
            $response->status(200);
            QYS::bye();
            return;
        }
    }

}
